import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
const login = r => require.ensure([], () => r(require('../views/login')), 'login')
const manage = r => require.ensure([], () => r(require('../views/leftNav')), 'leftNav')
const home = r => require.ensure([], () => r(require('../views/home')), 'home')

// const addPolicy = r => require.ensure([], () => r(require('../views/policyManagement/addPolicy')), 'addPolicy') // 政策添加
// const policyList = r => require.ensure([], () => r(require('../views/policyManagement/policyList')), 'policyList') // 政策列表
//
// const approvalFullGift = r => require.ensure([], () => r(require('../views/audit/approvalFullGift')), 'approvalFullGift') // 买赠审核
// const approvalDiscounts = r => require.ensure([], () => r(require('../views/audit/approvalDiscounts')), 'approvalDiscounts') // 打折审核
//
// const categoryManagement = r => require.ensure([], () => r(require('../views/productManagement/categoryManagement')), 'categoryManagement') // 品类管理
// const specificationManagement = r => require.ensure([], () => r(require('../views/productManagement/specificationManagement')), 'specificationManagement') // 规格管理
// const productManagement = r => require.ensure([], () => r(require('../views/productManagement/productManagement')), 'productManagement') // 产品管理
//
// // const orderAudit = r => require.ensure([], () => r(require('../views/orderManagement/orderAudit')), 'orderAudit') // 订单审批
// const orderList = r => require.ensure([], () => r(require('../views/orderManagement/orderList')), 'orderList') // 订单列表
//
// // const roleManagement = r => require.ensure([], () => r(require('../views/systemManagement/roleManagement')), 'roleManagement') // 角色管理
// // const userManagement = r => require.ensure([], () => r(require('../views/systemManagement/userManagement')), 'userManagement') // 用户管理
//
// const personalInformation = r => require.ensure([], () => r(require('../views/personalCenter/personalInformation')), 'personalInformation') // 个人信息
// const addressManagement = r => require.ensure([], () => r(require('../views/personalCenter/addressManagement')), 'addressManagement') // 地址管理
//
// const shoppingCar = r => require.ensure([], () => r(require('../views/shoppingCar')), 'shoppingCar') // 我的购物车
// const myOrder = r => require.ensure([], () => r(require('../views/myOrder')), 'myOrder') // 我的订单
//
// const createOrder = r => require.ensure([], () => r(require('../views/createOrder/createOrder')), 'createOrder') // 生成订单
// const submitOrder = r => require.ensure([], () => r(require('../views/createOrder/submitOrder')), 'submitOrder') // 提交订单
// const productDetails = r => require.ensure([], () => r(require('../views/productDetails')), 'productDetails') // 商品详情

const routes = [
  {
    path: '/user/login',
    component: login
  }, {
    path: '',
    component: manage
  }, {
    path: '/',
    component: manage
  }, {
    path: '/manage',
    component: manage,
    children: [
      {
        path: '',
        component: home
      }, {
        path: '/',
        component: home
      }, {
        path: '/home',
        component: home
      }
      // {
      //   path: '/addPolicy',
      //   component: addPolicy,
      //   meta: ['政策添加', '政策添加']
      // }, {
      //   path: '/policyList',
      //   component: policyList,
      //   meta: ['政策列表', '政策列表']
      // }, {
      //   path: '/approvalFullGift',
      //   component: approvalFullGift,
      //   meta: ['买赠审核', '买赠审核']
      // }, {
      //   path: '/approvalDiscounts',
      //   component: approvalDiscounts,
      //   meta: ['打折审核', '打折审核']
      // }, {
      //   path: '/categoryManagement',
      //   component: categoryManagement,
      //   meta: ['品类管理', '品类管理']
      // }, {
      //   path: '/specificationManagement',
      //   component: specificationManagement,
      //   meta: ['规格管理', '规格管理']
      // }, {
      //   path: '/productManagement',
      //   component: productManagement,
      //   meta: ['产品管理', '产品管理']
      // }, {
      //   path: '/orderList',
      //   component: orderList,
      //   meta: ['订单列表', '订单列表']
      // }, {
      //   path: '/personalInformation',
      //   component: personalInformation,
      //   meta: ['个人信息', '个人信息']
      // }, {
      //   path: '/addressManagement',
      //   component: addressManagement,
      //   meta: ['地址管理', '地址管理']
      // }, {
      //   path: '/shoppingCar',
      //   component: shoppingCar,
      //   meta: ['我的购物车', '我的购物车']
      // }, {
      //   path: '/myOrder',
      //   component: myOrder,
      //   meta: ['我的订单', '我的订单']
      // }, {
      //   path: '/createOrder',
      //   component: createOrder,
      //   meta: ['生成订单', '生成订单']
      // }, {
      //   path: '/submitOrder',
      //   component: submitOrder,
      //   meta: ['提交订单', '提交订单']
      // }, {
      //   path: '/productDetails',
      //   component: productDetails,
      //   meta: ['商品详情', '商品详情']
      // }
    ]
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
